//
//  ZYCAttendanceRecordCalendarCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/10.
//

#import "ZYCAttendanceRecordCalendarCell.h"
#import "ZYCAttendanceStatusGroupView.h"
#import "ZYCAttendanceStatisiticModel.h"
@interface ZYCAttendanceRecordCalendarCell ()

@property (nonatomic, strong) ZYCAttendanceStatusGroupView *normalView;
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *lateView;
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *leaveView;
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *absentlView;
@end
@implementation ZYCAttendanceRecordCalendarCell

- (void)setModel:(ZYCAttendanceStatisiticModel *)model{
    _model = model;
    _normalView.count = model.countZC;
    _lateView.count = model.countCD;
    _leaveView.count = model.countQJ;
    _absentlView.count = model.countWD;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.normalView];
        [self.contentView addSubview:self.lateView];
        [self.contentView addSubview:self.leaveView];
        [self.contentView addSubview:self.absentlView];

        CGFloat margin  = (kScreenWidth  - 50 * 4) / 5;
        
        [self.normalView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.contentView).offset(margin);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.lateView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.normalView.mas_right).offset(margin);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.leaveView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.lateView.mas_right).offset(margin);
            make.centerY.equalTo(self.contentView);
        }];
        [self.absentlView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.leaveView.mas_right).offset(margin);
            make.centerY.equalTo(self.contentView);
        }];

    }
    return self;
}

- (ZYCAttendanceStatusGroupView *)normalView {
    if (!_normalView) {
        _normalView = [[ZYCAttendanceStatusGroupView alloc] init];
        _normalView.title = @"正常";
        _normalView.color = HEX_RGB(@"#39A85B");
    }
    return _normalView;
}

- (ZYCAttendanceStatusGroupView *)lateView {
    if (!_lateView) {
        _lateView = [[ZYCAttendanceStatusGroupView alloc] init];
        _lateView.title = @"迟到";
        _lateView.color = HEX_RGB(@"#E93C06");
    }
    return _lateView;
}

- (ZYCAttendanceStatusGroupView *)leaveView {
    if (!_leaveView) {
        _leaveView = [[ZYCAttendanceStatusGroupView alloc] init];
        _leaveView.title = @"请假";
        _leaveView.color = HEX_RGB(@"#FDA252");

    }
    return _leaveView;
}

- (ZYCAttendanceStatusGroupView *)absentlView {
    if (!_absentlView) {
        _absentlView = [[ZYCAttendanceStatusGroupView alloc] init];
        _absentlView.title = @"未到";
        _absentlView.color = HEX_RGB(@"#B9B9B9");

    }
    return _absentlView;
}

@end
